<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<%@ include file="/commons/meta.jsp" %>
   	<link href="<c:url value="/widgets/simpletable/simpletable.css"/>" type="text/css" rel="stylesheet">
   	<link href="${ctx }/styles/css_uax.css" rel="stylesheet" type="text/css" />
   	
   	<style>
	.black_overlay{ 
            display: none; 
            position: absolute!important; 
            top: 0px; 
            left: 0px; 
            width:100%; 
            height:100%!important; 
            background-color:#eee;
            z-index:1001; 
            -moz-opacity: 0.5; 
            opacity:.50; 
            filter: alpha(opacity=50); 
        } 
        .white_content { 
            display: none; 
            position: absolute; 
            top: 25%; 
            left: 25%; 
            width: 500px; 
            height: 300px; 
            padding: 16px; 
            border: 16px solid orange; 
            background-color: white; 
            z-index:1002; 
            overflow: auto; 
        }
	</style>
</head>

<body style="height:100%">
  
<%@include file="/commons/top.jsp" %>
<div id="fade" class="black_overlay">&nbsp;</div> 
  	<div id="sub-header" class="twidth">
  	<div id="navsub">
		<div class="l"></div>
		<div class="r"></div>
		<div class="m">
		<div style="width:600px;float:left;">
			<a href="${ctx}">首页</a> → <a href="">我联系过的工人信息</a>
		</div>
		</div>
	</div>
	
<table>
<tr>
<td style="vertical-align:top">
	<%@ include file="/front/Members/memberLeft.jsp" %>
</td>
<td>
<div id="middle">
<div id="directory" class="mframe mR" style="width:724px;float:left;">
	<div style="width:710px;float:left;margin-left: 20px;">
<div id="directory" class="mframe mR" style="float:left;">
      <!-- Content -->
	  <div id="page" class="box">
	  <c:if test="${page.totalCount>0}">
		<ol class="results" style="padding-left: 10"> 
		 <s:iterator value="#request.page.result" var="item" >
		 	  <div class="mframe mR">
			<div class="tl"></div>
			<div class="tr"></div>
			<div class="tm">
				<span class="tt"><a target="_blank" class="title" href="${ctx}/PublishInfo/show.do?publishInfoId=${item.publishInfoId}"> ${item.publishInfo.name} </a></span>
			</div>
			<div class="wrapper">
			<div class="ml"></div>
			<div class="mr"></div>
			<div class="mm">
			
		 	<p>
		 	姓名：<a target="_blank" class="title" href="${ctx}/PublishInfo/show.do?publishInfoId=${item.publishInfoId}">
			${item.publishInfo.category.categoryName} - ${item.publishInfo.name}</a>
			<a  target="_blank" href="${ctx}/PublishInfo/list.do?categoryId=${item.publishInfo.categoryId}" class="addr">${item.publishInfo.cityTwo}</a>
			-<a target="_blank" href="${ctx}/PublishInfo/list.do?cityId=${item.publishInfo.cityId}&categoryId=${item.publishInfo.categoryId}" class="addr">${item.publishInfo.cityThree}</a>
			 电话：${item.publishInfo.phone}
			 <s:if test="%{#item.status==2}">
			 	&nbsp;<label style="color:#8c2722">已评价</label>
			 </s:if>
			 <s:else>
			 	<a href="javascript:void(0);openComment(${item.publishInfo.publishInfoId},${item.publishInfo.memberId},${item.myContactId})" style="margin-left: 30px;right:50px"> 我要评价他 </a>
			 </s:else>
			 </p>
			 
			 </div>
			</div>
			<div class="bl"></div>
			<div class="br"></div>
			<div class="bm"></div>
		</div>
		 </s:iterator>
		</ol>
		</c:if>
		<simpletable:pageToolbar page="${page}"  isShowPageSizeList="false">
		</simpletable:pageToolbar>
	  </div>
    </div>
	<div id="light" class="white_content">
		<a href = "javascript:void(0)" style="float:right;padding:0;margin:0;" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">关闭</a>
		<br />
		<label id="autoRedirect" style="display:none"></label>
		<div id="attitudeDiv">							
		<label style="margin:0px 0px 20px 20px;font-weight: bold;color:#9c2722;">我要评价他的服务态度</label>
		<br />
	 	<div style="padding-left: 15px;margin: 10px 0px 20px 20px;">
		<input type="radio" id="attitude0" name="attitude" value="-1" onclick="doSetAttitude(-1)"  /><label for="attitude0" onclick="doSetAttitude(-1)">态度较差</label>&nbsp;&nbsp;
		<input type="radio" id="attitude2" name="attitude" value="1"  onclick="doSetAttitude(1)"/><label for="attitude2" onclick="doSetAttitude(1)">态度一般</label>&nbsp;&nbsp;
		<input type="radio" id="attitude4" name="attitude" value="2"  onclick="doSetAttitude(2)"/><label for="attitude4" onclick="doSetAttitude(2)">态度良好</label>&nbsp;&nbsp;
		<input type="radio" id="attitude6" name="attitude" value="3"  onclick="doSetAttitude(3)"/><label for="attitude6" onclick="doSetAttitude(3)">态度优秀</label>&nbsp;&nbsp;
	   </div>
	   </div>
	   
	   <div>
	   <label style="margin:0px 0px 20px 20px;font-weight: bold;color:#9c2722;">我要评价他的服务质量</label>
		<div style="padding-left: 10px;margin: 10px 0px 0px 20px;">
		<input type="radio" id="quality0" name="quality" value="-1" onclick="doSetquality(-1)"  /><label for="quality0" onclick="doSetquality(-1)">态度较差</label>&nbsp;&nbsp;
		<input type="radio" id="quality2" name="quality" value="1"  onclick="doSetquality(1)"/><label for="quality2" onclick="doSetquality(1)">态度一般</label>&nbsp;&nbsp;
		<input type="radio" id="quality4" name="quality" value="2"  onclick="doSetquality(2)"/><label for="quality4" onclick="doSetquality(2)">态度良好</label>&nbsp;&nbsp;
		<input type="radio" id="quality6" name="quality" value="3"  onclick="doSetquality(3)"/><label for="quality6" onclick="doSetquality(3)">态度优秀</label>&nbsp;&nbsp;
	   </div>
	   </div>
	   
	   <br />
	   <label style="margin:10px 0px 20px 20px;font-weight: bold;color:#9c2722;">一句话评价他/她</label>
	   
	   <s:textarea id="contents" theme="simple" cols="40" rows="5"></s:textarea>
	   
	   <div style="padding-left: 10px;margin: 10px 0px 0px 20px;text-align: center">
	   <input type="button" onclick="doComment()" value="提交评论" />
	   </div>
	   
	   <div id = "commentsReturn" style="height:20px;margin-top: 10px;text-align: center;color: red;font-weight: bold"></div>
					
	</div> 
  	</div>

</td>
</tr>
</table>	

	
  	<jsp:include page="/commons/bottom.html"  flush="true"></jsp:include>
  </div>
  
<script>
	var flag=0;
	var publishInfoId,attitudeValue,qualityValue,publishMemberId,myContactId;
	new Validation(document.forms[0],{onSubmit:true,onFormValidate : function(result,form) {
		var finalResult = result;
		
		//在这里添加自定义验证
		
		return disableSubmit(finalResult,'submitButton');
	}});
	
	function openComment(objId,memberId,contactId){
		document.getElementById('light').style.display='block';
		document.getElementById('fade').style.display='block';
		publishInfoId = objId;
		var json ={};
		json.publishInfoId = objId;
		json.memberId=  ${session.memberInfo.memberId};
		publishMemberId = memberId;
		myContactId = contactId;
		$.ajax(
			{url:"${ctx}/Comments/check.do",
			data:json,
			success:function responseData(jsonData){
				if(jsonData=='1'){
					flag =1;
					document.getElementById("attitudeDiv").style.display = "none";
				}else{
					document.getElementById("attitudeDiv").style.display = "";
					flag =0;
					document.getElementById("commentsList").innerHTML += jsonData;
				}
			}
			}
		);
	}
	
	function doComment(){
		var json ={};
		json.publishInfoId = publishInfoId;
		json.attitude =  attitudeValue;
		json.quality =  qualityValue;
		json.memberId=  publishMemberId;
		json.flag = flag;
		json.contents = document.getElementById("contents").value;
		json.myContactId = myContactId;
		$.ajax(
			{url:"${ctx}/Comments/save.do",
			data:json,
			success:function responseData(jsonData){
				if(jsonData=='1'){
					alert("请先登录再发表评论");
				}else if(jsonData=='3'){
					alert("不可评价自己发布的信息");
				}else
				{
					document.getElementById("commentsReturn").innerHTML = jsonData;
				}
			}
			}
		);
	}
	
	function doSetAttitude(obj){
		attitudeValue = obj;
	}
	function doSetQuality(obj){
		qualityValue = obj;
	}
</script>
<script>
  	document.getElementById("indexPage").className="thisclass";
  	//document.getElementById("psnPage").className="thisclass";
  </script>
</body>
</html>